package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.OrderComment;
import com.briup.jz.bean.extend.OrderCommentExtend;
import com.briup.jz.service.IOrderCommentService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(description="订单评论相关接口")
@Validated
@RestController
@RequestMapping("/orderComment")
public class OrderCommentController {
	
	@Autowired
	private IOrderCommentService orderCommentService;
<<<<<<< HEAD

=======
	
>>>>>>> 0ee4b77104e315823a1532fd59eef38881b787c5
	@ApiOperation(value="按id查询订单评论信息")
	@GetMapping("query")		
	    public Message query(Long id) {
			List<OrderComment> list = orderCommentService.query(id);
			return MessageUtil.success(list);
	    }

	
	@ApiOperation("级联查询所有评论信息")
	@GetMapping("queryCascade")
	public Message queryCascade(String content,String status,Long orderId) {
		List<OrderCommentExtend> list = orderCommentService.queryCascade(content, status, orderId);
		return MessageUtil.success(list);
	}
	
		
	@ApiOperation(value="查询订单评论是否通过")
	@GetMapping("check")		
	    public Message checkPass(String content,String status,Long orderId) {
			List<OrderComment> list = orderCommentService.check(content,status,orderId);
			return MessageUtil.success(list);
	    }
	
<<<<<<< HEAD
	
=======
>>>>>>> 0ee4b77104e315823a1532fd59eef38881b787c5
	 @ApiOperation(value = "通过id删除评论信息")
	 @GetMapping("deleteById")
	 @ApiImplicitParams({
	 @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
	    })
	public Message deleteById(@NotNull Long id) {
		orderCommentService.deleteById(id);
		return MessageUtil.success("删除成功");
		
	}
	 
	 
	 @ApiOperation(value = "保存或更新订单评论信息")
	    @ApiImplicitParams({
	            @ApiImplicitParam(name="id",value = "订单评论编号",paramType = "form"),
	            @ApiImplicitParam(name="content",value = "评论内容",paramType = "form"),
	            @ApiImplicitParam(name="commentTime",value = "评论时间",paramType = "form"),
	            @ApiImplicitParam(name="status",value = "评论状态",paramType = "form"),
	            @ApiImplicitParam(name="orderId",value = "订单id",paramType = "form"),
	            @ApiImplicitParam(name="customerId",value = "顾客id",paramType = "form"),
	    }) 
	 
	 @PostMapping("saveOrUpdate")
		public Message saveOrUpdate(OrderComment orderComment) {
			orderCommentService.saveOrUpdate(orderComment);
			return MessageUtil.success("更新成功");
			
		}
	 
		/*分页*/
		@GetMapping("pageQuery")
		@ApiOperation(value = "分页查询")
	    @ApiImplicitParams({
	    	@ApiImplicitParam(name="page",value = "页码",paramType = "form",required = true),
	    	@ApiImplicitParam(name="pageSize",value = "每页记录数",paramType = "form",required = true),
	    	@ApiImplicitParam(name="content",value = "评论内容",paramType = "form"),
	    	@ApiImplicitParam(name="status",value = "状态",paramType = "form"),
	        @ApiImplicitParam(name="orderId",value = "订单评论id",paramType = "form")
	    })
		public Message pageQuery(int page, int pageSize, String content, String status, Long orderId) {
			List<OrderCommentExtend> orderCommentExtends = orderCommentService.pageQuery(page, pageSize, content, status, orderId);
			return MessageUtil.success(orderCommentExtends);
		}
		
	 
}
